// $Header: $

using System;
using System.Data;
using System.Collections.Generic;

namespace LogParser.DA
{
    /// <summary>
    /// Summary description for LogParser.DA.KillsStatsModel.
    /// </summary>
    public class KillsStatsModel
    {
        #region Private Member Variables

        #endregion

        #region Constructor
        /// <summary>
        /// Initializes a new instance of the <see cref="KillsStatsModel"/> class.
        /// </summary>
        public KillsStatsModel()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        #endregion

        #region Public Properties

        #endregion

        #region Private Properties

        #endregion

        #region Public Member Functions

        public static int GetKillsTotalCount()
        {
            DA.DataObjects.KillsDSTableAdapters.KillsTableAdapter kta = TableAdapters.KillsTableAdapter();

            int killCount = (int) kta.KillsCountSelect();

            return killCount;
        }

        public static List<LogParser.Kill> KillsSelect( int logId )
        {
            List<LogParser.Kill> killList = new List<Kill>();

            DA.DataObjects.KillsDSTableAdapters.KillsTableAdapter kta = TableAdapters.KillsTableAdapter();

            DA.DataObjects.KillsDS.KillsDataTable dt = kta.KillsSelectByLogId( logId );

            foreach ( DA.DataObjects.KillsDS.KillsRow dr in dt )
            {
                LogParser.Kill tempkill = new Kill();
                LogParser.Position victimPosition = new Position();

                victimPosition.X = dr.Victim_pos_x;
                victimPosition.Y = dr.Victim_pos_y;
                victimPosition.Z = dr.Victim_pos_z;

                LogParser.Position attackerPosition = new Position();
                attackerPosition.X = dr.Attacker_pos_x;
                attackerPosition.Y = dr.Attacker_pos_y;
                attackerPosition.Z = dr.Attacker_pos_z;


                tempkill.KillTime = dr.KillTime;

                Collections.ClassList cl = new LogParser.Collections.ClassList();
                tempkill.VictimClass = ( (GameObjects.Class) cl.GetClass( dr.Victim_classId ) ).LongName;
                tempkill.AttackerClass = ( (GameObjects.Class) cl.GetClass( dr.Attacker_classId ) ).LongName;

                Collections.TeamList tl = new LogParser.Collections.TeamList();
                tempkill.AttackerTeam = ( (GameObjects.Team) tl.GetTeam( dr.Attacker_team ) ).Name;
                tempkill.VictimTeam = ((GameObjects.Team) tl.GetTeam( dr.Victim_team ) ).Name;


                Collections.WeaponList wl = new LogParser.Collections.WeaponList();
                tempkill.Weapon = ( (GameObjects.Weapon) wl.GetWeapon( dr.Attacker_weaponId ) ).FullName;

                Player attackerPlayer = PlayerModel.GetPlayer( dr.Attacker_playerId );
                Player victimPlayer = PlayerModel.GetPlayer( dr.Victim_playerId );

                tempkill.Attacker = attackerPlayer;
                tempkill.Victim = victimPlayer;

                tempkill.AttackerPosition = attackerPosition;
                tempkill.VictimPosition = victimPosition;

                killList.Add( tempkill );
            }

            return killList;
        }

        #endregion

        #region Private Member Functions

        #endregion
    }
}

#region VSS Log

/*
 * $Log: $
 */

#endregion VSS Log